package org.smartboot.compare;

import java.lang.invoke.MethodHandle;
import java.lang.reflect.Field;

/**
 * @author qinluo
 * @date 2024-08-19 21:19:52
 * @since 1.1.3
 */
public class MethodHandleFieldReader implements FieldReader {

    private final MethodHandle methodHandle;

    public MethodHandleFieldReader(MethodHandle methodHandle) {
        this.methodHandle = methodHandle;
    }

    @Override
    public Object read(Field f, Object target) throws Throwable {
        return methodHandle.invoke(target);
    }
}
